#!/bin/bash
echo test > testfile && \
openssl genrsa -out rsa.key 3072 && \
openssl req -new -out rsa.csr -key rsa.key -subj "/C=AA/ST=BB/O=CC/OU=DD/CN=test" && \
openssl x509 -req -in rsa.csr -out rsa.crt -signkey rsa.key -days 3650 && \
openssl pkcs12 -export -in rsa.crt -inkey rsa.key -out rsa.p12 -password pass:abc123 && \
./p12_rsasign rsa.p12 abc123 testfile testfile.sig && \
openssl x509 -in rsa.crt -pubkey -out rsa.pub && \
openssl dgst -sha256 -verify rsa.pub -signature testfile.sig testfile && \
echo "selftest ok!"